package com.chinasofti.Servlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/index")
public class IndexServelt extends HttpServlet {
    @Override
    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        response.setContentType("txt/html;charset=UTF-8");
        Cookie[] cookies=request.getCookies();
        String abc = null;

        for (Cookie a:cookies){
            abc = a.getValue();
           if (a.getName().equals("username")){
               break;
           }
        }
     /*   System.out.println("测试"+abc);*/
        response.getWriter().write(abc);
    }
}
